resource "google_container_cluster" "primary" {
  name               = "<%= ctx[:vars]['cluster_name'] %>"
  location           = "us-central1-a"
  initial_node_count = 1
  workload_identity_config {
    identity_namespace = "<%= ctx[:test_env_vars]['project'] %>.svc.id.goog"
  }
}

resource "google_gke_hub_membership" "membership" {
  membership_id = "<%= ctx[:vars]['name'] %>"
  endpoint {
    gke_cluster {
      resource_link = google_container_cluster.primary.id
    }
  }
  authority {
    issuer = "https://container.googleapis.com/v1/${google_container_cluster.primary.id}"
  }
}
